package com.pagoda.nerp.web.entities;

import com.pagoda.nerp.web.common.buildTree.TreeNode;
import com.pagoda.nerp.web.util.DatetimeAdapter;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;


import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
import java.util.Date;

@Entity
@Data
@NoArgsConstructor
@AllArgsConstructor
@Table(name = "hrunit")
@XmlRootElement(name="hrunit")
public class HRUnit implements TreeNode {
    @Id
    private String orguid;

    private String parentnm;

    private String orgname;

    private String orgcode;

    private Integer orgtype;

    private String mgrcode;

    private String mgrname;

    private String mgrphone;

    private Date modifytime;

    private Integer js;

    private String orgalias;

    private Integer mx;

    private String canonicalcode;

    private String canonicalparentcode;

    @XmlElement(name = "modifytime")
    @XmlJavaTypeAdapter(DatetimeAdapter.class)
    public Date getModifytime() {
        return modifytime;
    }

    @Override
    public String getCode() {
        return this.canonicalcode;
    }

    @Override
    public String getParentCode() {
        return this.canonicalparentcode;
    }

    @Override
    public String getName() {
        return this.orgname;
    }

    @Override
    public String toString() {
        return "HRUnit{" +
                "orguid='" + orguid + '\'' +
                ", parentnm='" + parentnm + '\'' +
                ", orgname='" + orgname + '\'' +
                ", orgcode='" + orgcode + '\'' +
                ", orgtype=" + orgtype +
                ", mgrcode='" + mgrcode + '\'' +
                ", mgrname='" + mgrname + '\'' +
                ", mgrphone='" + mgrphone + '\'' +
                ", modifytime=" + modifytime +
                ", js=" + js +
                ", orgalias='" + orgalias + '\'' +
                ", mx=" + mx +
                ", canonicalcode='" + canonicalcode + '\'' +
                ", canonicalparentcode='" + canonicalparentcode + '\'' +
                '}';
    }
}
